<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>box2</title>
	<style type="text/css">
	.box{
		width: 200px;
		height: 200px;
		background: red url() 0 0 no-repeat;
		position: absolute;/*相对body绝对定位*/
		top: 0px;
		left: 0px;
	}
	</style>
</head>
<body>
	<div class="box" id="box">
		
	</div>
	<script type="text/javascript">
	var box=document.getElementById('box');
	function run(){
		top1 = Math.round((Math.random()*400));
		left1 = Math.round((Math.random()*1000));
		box.style.top=top1+'px';
		box.style.left=left1+'px';
	}

	var time=setInterval(run,500);
	box.onmouseover = function  () {
			clearInterval(time);
	}
	box.onmouseout = function  () {
			time = setInterval(run, 500);
		}
	
	</script>
</body>
</html>